package com.design;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

import com.receive.ClientRecv;

public class LoginDesign implements ActionListener{
	public static JFrame mainform;
	JPanel top, middle, bottom, bottom1;
	JPanel mainpanel, payment, accounts, smsbanking, estatement;
	JButton bpayment, baccounts, bsmsbanking, bestatement;
	Layers layers = new Layers();
	JMenuBar mb;
	JMenu reg, pay, acc, sms, est;
	JMenuItem pay1, pay2, pay3, acc1, acc2, acc3, sms1,log,regs1;
	JPanel temp = new JPanel();

	public LoginDesign() {
		mainform = new JFrame();

		ClientRecv clientRecv = new ClientRecv();
		mainform.setTitle("Login");
		Dimension di = mainform.getToolkit().getScreenSize();
		int width = di.width;
		int height = di.height;
		int wi = (width - 800) / 2;
		int he = (height - 600) / 2;

		mainpanel = new JPanel();
		mainpanel.setLayout(null);

		top = new JPanel();
		top.setLayout(new FlowLayout());
		top.setBackground(new Color(171, 12, 87));
		top.setBounds(0, 0, 800, 100);

		JLabel tit = new JLabel("E-BANKING");
		tit.setForeground(Color.yellow);
		tit.setFont(new Font("verdana", Font.BOLD, 15));
		top.add(tit);

		mainpanel.add(top);
		middle = new JPanel();
		middle.setLayout(new BorderLayout());
		middle.setBackground(new Color(171, 12, 87));
		middle.setBounds(0, 100, 800, 30);

		/*************************************/
		middle.add(menudet());
		/*************************************/
		mainpanel.add(middle);

		bottom = new JPanel();
		bottom.setLayout(null);
		// bottom.setBackground(new Color(0,0,0));
		bottom.setBounds(0, 130, 800, 450);

		bottom1 = new JPanel();
		bottom1.setLayout(new BorderLayout());
		bottom1.setBackground(new Color(171, 12, 87));
		bottom1.setBounds(0, 580, 800, 450);
		mainpanel.add(bottom1);
		Layers layers = new Layers();
		bottom = layers.Login(bottom);
		/*
		 * accounts=new JPanel(); smsbanking=layers.SmsBanking(); estatement=new
		 * JPanel();
		 */
		// bottom.add(payment);
		mainpanel.add(bottom);

		mainform.add(mainpanel);
		mainform.setLocation(wi, he);
//		mainform.setUndecorated(true);
		mainform.setSize(800, 600);
		mainform.setVisible(true);

	}

	public JMenuBar menudet() {
		mb = new JMenuBar();
		mb.setLayout(new GridLayout(1, 5));
		mb.setBackground(new Color(171, 12, 87));

		reg = new JMenu("Home");
		reg.setForeground(Color.YELLOW);
		reg.setFont(new Font("Comic Sans Ms", Font.BOLD, 15));
		log=new JMenuItem("Login");
		regs1=new JMenuItem("Registration");
		reg.add(log);
		reg.add(regs1);
		mb.add(reg);
		regs1.addActionListener(this);
		log.addActionListener(this);
		return mb;
	}

	public static void main(String[] args) {
		new LoginDesign();
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==regs1)
		{
			RemoveComp(bottom);
			System.out.println("AAAAAAAAAAA");

			mainpanel.add(layers.Registration(bottom));
			
			mainform.repaint();
			mainpanel.repaint();
			bottom.repaint();
	
		}
		else if(e.getSource()==log)
		{
			RemoveComp(bottom);
			System.out.println("AAAAAAAAAAA");

			mainpanel.add(layers.Login(bottom));
			
			mainform.repaint();
			mainpanel.repaint();
			bottom.repaint();
		}
		
	}
	public void RemoveComp(JPanel bot)
	{
		bot.removeAll();
	}
}
